<!--index.html-->
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" charset="utf-8">
</head>
<body>
<button onclick="myFunction()">onAlert</button>
<script>
    function myFunction() {
      alert("Hello World");
    }
</script>
<a href="https://www.baidu.com">onBeforeUnload</a>
<script>
    function myFunction() {
      return "onBeforeUnload Event";
    }
</script>
<button onclick="myFunction()">onConfirm</button>
<p id="demo"></p>
<script>
    function myFunction() {
      let x;
      let r = confirm("click button!");
      if (r == true) {
        x = "ok";
      } else {
        x = "cancel";
      }
      document.getElementById("demo").innerHTML = x;
    }
</script>
</body>
</html>